home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Communications Toolbox / CTB Development Resources / CTB Custom Choose / CustomChoose Outline
Encoding:
Text File  |  1992-05-13  |  4.0 KB  |  93 lines  |  [TEXT/MPS ]

  1.                                                             Authors
  2.                                                             -------
  3.                                                             Craig Hotchkiss
  4.                                                             Chris Halim
  5.  
  6. Steps to create your own choose dialog:
  7. =======================================
  8. ASSUMPTIONs - In the following text, xx can currently be CM, FT, or TM (the future 
  9. does hold other possibilities).  For example, xxChoose could be CMChoose, FTChoose, 
  10. or TMChoose.
  11.  
  12.     InitGlobals
  13.     Create storage -- This step is necessary to create the private storage needed 
  14.         by CTB and the tools for dialog operation.  The CTB calls will 
  15.         dereference your pointer and expect the first 6 bytes of this structure to be:
  16.             2 bytes (short) - tool procID - A.K.A. tool refNum.
  17.             4 bytes (long) - internal tool use.
  18.         NOTE -- Remember that you can extend this structure to include any private
  19.         storage -- similar to using a pointer to the following structure as a WindowPtr:
  20.             struct {
  21.                 WindowRecord        fWRecord;
  22.                 Ptr                    fPrivateStorage;
  23.             } myWindowRec, *myWindowPtr;
  24.         you can also create your own private storage by extending the structure that
  25.         the CTB calls expect.  Here's an example:
  26.             struct {
  27.                 short            fProcID;            // for CTB
  28.                 long            fMagicCookie;        // for CTB
  29.                     /* now we're free to add our own stuff.
  30.                 Ptr                fConfigPtr;            // for our use
  31.                 short            fItemCount;            // for our use
  32.                 ProcPtr            fIdleProc;            // for our use
  33.                     etc...
  34.             } ChooseDLOGData, *ChooseDLOGDataPtr;
  35.     GetNewDialog - This is a dialog that contains the common elements between
  36.         tools.  For those folks who have seen the xxChoose dialog, an example of this
  37.         dialog would be a small window frame just large enough to contain non-tool-
  38.         specific items like OK and Cancel buttons, the tool name popup menu, and 
  39.         the dotted line.  The tool appends its item list to this "base" dialog so 
  40.         the frame of the window itself only needs to encompass the items you provide.
  41.     Perform any dialog positioning.
  42.     Set window refCon to the storage ptr you created in the first step -- this is
  43.         necessary in preparation for the xxSetupxx calls to come.
  44.     Save CurResFile().
  45.     Save the current grafPtr.
  46.     Set the new grafPtr to the dialog.
  47.     Set CurResFile() to the procID of the tool we're working with (the tool procID
  48.         is also the refNum of the open file).
  49.     Call xxSetupPreflight
  50.     Call AppendDITL with handle to itemList that xxSetupPreflight returns.
  51.     Call xxSetupSetup to display the items.
  52.     Do ModalDialog with a filter proc
  53.     Modal Filter proc
  54.         Perform any other normal event handling
  55.         Set CurResFile() to the procID of the tool we're working with (the tool procID
  56.             is also the refNum of the open file).
  57.         Call xxSetupFilter
  58.         Call the idleProc if provided
  59.     END
  60.     While the itemHit is NOT OK or Cancel
  61.         Handle any others items we provide
  62.                 or
  63.         If the itemHit > itemCount it must be a CTB item
  64.         Set CurResFile() to the procID of the tool we're working with (the tool 
  65.             procID is also the refNum of the open file).
  66.         Call xxSetupItem
  67.     END
  68.     Important - Set the new grafPtr to the dialog.
  69.     Set CurResFile() to the procID of the tool we're working with (the tool procID
  70.         is also the refNum of the open file).
  71.     Call xxSetupXCleanup
  72.     Call ShortenDITL
  73.     Call xxPostflight
  74.     Cleanup any private items you provide. 
  75.     Restore the saved GrafPtr
  76.     Restore the saved CurResFile()
  77.     If OK was hit, update the configuration record and validate it else do nothing.
  78.  
  79.  
  80. -------------------------------------------------------------------------------------
  81. DISCLAIMER - This paper contains hints to assist CommToolbox software developers with 
  82. their efforts at producing awesome products.  They are just hints (a form of help) 
  83. however, and are not intended to represent the only possible solution.  
  84.  
  85. It should also be noted that this paper describes current CommToolbox interface 
  86. usage and while the CTB interface could change, upwards-compatibility will remain a 
  87. focus of the CTB production team wherever possible.  Therefore the hints contained 
  88. in this document that use the changing CTB interface represent a solution that should
  89. remain viable.
  90.                         -------------------------------------
  91.                           Copyright © 1992 Apple Computer, Inc.
  92.                           All rights reserved.
  93.